package com.example.fbi_text.views;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.fbi_text.R;

public class Mainitem02View extends RelativeLayout {
    private ImageView mImage;
    private TextView mtitle02;
    private TextView mcontent02;
    private TextView mauthor02;
    public Mainitem02View(Context context) {
        super(context);
        initView();
    }

    public Mainitem02View(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }
    public void initView(){
        LayoutInflater.from(getContext()).inflate(R.layout.main_item01,this,true);
        mtitle02 = findViewById(R.id.main_item02_title);
        mcontent02 = findViewById(R.id.main_item02_content);
        mauthor02 = findViewById(R.id.main_item02_author);
        mImage = findViewById(R.id.main_item02_img);
    }
    public void setmtitle02(String title){
        if (mtitle02 != null && !TextUtils.isEmpty(title)){
            mtitle02.setText(title);
        }
    }
    public void setmcontent02(String content){
        if (mcontent02 != null && !TextUtils.isEmpty(content)){
            mcontent02.setText(content);
        }
    }
    public void setmauthor02(String author){
        if (mauthor02 != null && !TextUtils.isEmpty(author)){
            mauthor02.setText(author);
        }
    }
    public void setmImageSrc(String src){
        if (mImage != null && !TextUtils.isEmpty(src)){
            mImage.setImageResource(Integer.parseInt(src));
        }

    }

}
